/* 画布页面样式 - 参考 Generate 页面 */
.main-content {
  min-height: 100vh;
  height: 100vh;
  background: #0a0a0a;
  color: #ffffff;
  position: relative;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* 禁止页面滚动 */
}

/* 禁止整个页面的滚动 */
body {
  overflow: hidden;
}

html {
  overflow: hidden;
}

/* 针对 Gallery 页面，禁止外层容器的滚动 */
.main-content-wrapper {
  overflow: hidden !important;
}

/* 工具栏样式 - 固定定位 */
.canvas-toolbar {
  position: fixed;
  top: 80px;
  left: 36px; /* 为侧边栏留出空间 */
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}


.tool-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-wrap: wrap;
}

/* 颜色选择器样式 */
.color-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.color-picker label {
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
}

.color-options {
  display: flex;
  gap: 6px;
}

.color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn.active {
  border-color: #00cae0;
  box-shadow: 0 0 0 2px rgba(0, 202, 224, 0.3);
}

.color-btn.active::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #000;
  font-size: 12px;
  font-weight: bold;
}

.color-btn[style*="background-color: rgb(255, 255, 255)"]:not(.active) {
  border-color: #ccc;
}

.color-btn[style*="background-color: rgb(255, 255, 255)"].active::after {
  color: #000;
}

.color-btn[style*="background-color: rgb(0, 0, 0)"].active::after {
  color: #fff;
}

/* 颜色下拉框样式 */
.color-dropdown {
  position: relative;
  display: inline-block;
}

.color-dropdown-trigger {
  background-color: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #ffffff;
  padding: 6px 12px;
  font-size: 12px;
  min-width: 120px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-dropdown-trigger:hover {
  border-color: #666;
  background-color: #333;
}

.color-dropdown-trigger:focus {
  outline: none;
  border-color: #00cae0;
  box-shadow: 0 0 0 2px rgba(0, 202, 224, 0.2);
}

.color-preview {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #666;
  flex-shrink: 0;
}

.color-name {
  flex: 1;
  text-align: left;
}

.color-arrow {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.color-dropdown-trigger:active .color-arrow {
  transform: rotate(180deg);
}

.color-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-height: 200px;
  overflow-y: auto;
}

.color-dropdown-item {
  width: 100%;
  background: none;
  border: none;
  color: #ffffff;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.2s ease;
}

.color-dropdown-item:hover {
  background-color: #333;
}

.color-dropdown-item.active {
  background-color: #00cae0;
  color: #000000;
}

.color-dropdown-item.active .color-preview {
  border-color: #000000;
}

/* 画笔大小控制器样式 */
.brush-size {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.brush-size label {
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
}

.brush-slider {
  width: 80px;
  height: 4px;
  background: #374151;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.brush-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: #00cae0;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
}

.brush-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.brush-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #00cae0;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.brush-size-value {
  color: #ffffff;
  font-size: 11px;
  font-weight: 500;
  min-width: 30px;
  text-align: center;
}
  background: #2a2a2a;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid #333;
  min-width: 120px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #9aa5b1;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-width: 120px;
  justify-content: flex-start;
}

.tool-btn:hover {
  background: #3a3a3a;
  color: #e5eaf3;
}

.tool-btn.delete-btn {
  color: #dc3545;
}

.tool-btn.save-btn {
  color: #28a745;
}

.tool-btn.clear-btn {
  color: #ffc107;
}

.tool-btn.download-btn {
  color: #17a2b8;
}

.tool-btn.active {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.tool-icon {
  font-size: 16px;
}


/* 画布容器 - 固定高度 */
.canvas-container {
  width: 100%;
  height: 100%;
  /* height: 680px; */
  padding: 0;
  /* margin-top: 80px; */
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.canvas-area {
  /* width: 100%;
  height: 100%; */
  width: 680px;
  height: 680px;
  background: #2a2a2a;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
  background-image: 
    linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 20px 20px;
  transition: all 0.3s ease;
}
/* 空画布状态 */
.empty-canvas {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-zone {
  text-align: center;
  padding: 60px;
  border: 2px dashed #667eea;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
  cursor: pointer;
  transition: all 0.3s ease;
  max-width: 400px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-zone::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(102, 126, 234, 0.1) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.upload-zone:hover::before {
  transform: translateX(100%);
}

.upload-zone:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  border-color: #764ba2;
  transform: translateY(-4px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.8;
}

.upload-zone h3 {
  margin: 0 0 8px 0;
  font-size: 1.25rem;
  color: #667eea;
  font-weight: 600;
}

.upload-zone p {
  margin: 0;
  color: #9aa5b1;
  font-size: 0.875rem;
}

/* 画布图片 */
.canvas-image {
  position: absolute;
  cursor: move;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  user-select: none;
}

.canvas-image:hover {
  border-color: rgba(102, 126, 234, 0.5);
}

.canvas-image.selected {
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

.canvas-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.image-controls {
  position: absolute;
  top: -8px;
  right: -8px;
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  padding: 6px;
  border-radius: 8px;
  border: 1px solid rgba(102, 126, 234, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.2s ease-out;
}

.canvas-image:hover .image-controls {
  display: flex;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.control-btn {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #2a2a2a 0%, #3a3a3a 100%);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  color: #e5eaf3;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

.control-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(102, 126, 234, 0.2) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.control-btn:hover::before {
  transform: translateX(100%);
}

.control-btn:hover {
  background: linear-gradient(135deg, #3a3a3a 0%, #4a4a4a 100%);
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* 裁剪区域 */
.crop-area {
  position: absolute;
  border: 2px solid #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  cursor: move;
  pointer-events: none;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.3);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 1px rgba(102, 126, 234, 0.3);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  }
}

/* 选择区域 */
.selection-area {
  position: absolute;
  border: 2px dashed #667eea;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
  pointer-events: none;
  border-radius: 4px;
  animation: dash 1s linear infinite;
}

@keyframes dash {
  to {
    stroke-dashoffset: -20;
  }
}

/* 响应式设计 */
@media (max-width: 1440px) {
  .canvas-toolbar {
    display: none;
  }
}

@media (max-width: 1024px) {
  .canvas-toolbar {
    left: 90px;
    padding: 10px 14px;
  }
  
  .tool-btn {
    padding: 6px 12px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .canvas-toolbar {
    left: 20px;
    top: 20px;
    padding: 8px;
  }
  
  .tool-btn {
    padding: 10px 12px;
    min-width: 100px;
    font-size: 13px;
  }
  
  .tool-icon {
    font-size: 16px;
  }
  
  .upload-zone {
    padding: 40px 20px;
  }
  
  .upload-icon {
    font-size: 3rem;
  }
}

@media (max-width: 480px) {
  .canvas-toolbar {
    left: 10px;
    top: 10px;
    padding: 6px;
  }
  
  .upload-zone {
    padding: 30px 15px;
  }
  
  .upload-icon {
    font-size: 2.5rem;
  }
  
  .tool-btn {
    padding: 8px 10px;
    min-width: 80px;
    font-size: 12px;
  }
}

/* 图片容器样式 */
.image-container {
  position: relative;
}

/* 控制按钮样式 - 不受图片缩放影响 */
.image-controls {
  position: absolute;
  top: -40px;
  right: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  background: rgba(26, 26, 26, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  /* 关键：让按钮不受父元素的transform影响 */
  transform: scale(1) !important;
}

/* Fabric.js 画布容器 */
.fabric-canvas-container {
  width: 100%;
  height: 100%;
  min-height: 500px;
  position: relative;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
  background-size: 20px 20px;
  background-color: #0a0a0a;
  border-radius: 8px;
  overflow: hidden;
}

.fabric-canvas-container canvas {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  background: transparent !important;
}

/* 图层面板样式 */
.layers-panel {
  position: fixed;
  top: 80px;
  right: 20px;
  width: 360px;
  height: 680px;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 12px;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

.layers-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.layers-header h3 {
  margin: 0;
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
}

.toggle-panel-btn {
  background: none;
  border: none;
  color: #9aa5b1;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.toggle-panel-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.layers-list {
  flex: 1;
  overflow: hidden;
  padding: 8px;
  height: calc(680px - 60px); /* 减去头部高度 */
}

.no-layers {
  text-align: center;
  color: #9aa5b1;
  padding: 40px 20px;
  font-size: 14px;
}

.layer-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 12px;
}

.layer-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(102, 126, 234, 0.3);
}

.layer-item.selected {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.5);
}

.layer-preview {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.layer-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.layer-placeholder {
  font-size: 20px;
  opacity: 0.7;
}

.layer-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.layer-name {
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-type {
  color: #9aa5b1;
  font-size: 12px;
}

.layer-controls {
  display: flex;
  gap: 8px;
}

.visibility-btn {
  background: none;
  border: none;
  color: #9aa5b1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 16px;
}

.visibility-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* 显示图层面板按钮 */
.show-layers-btn {
  position: fixed;
  top: 80px;
  right: 20px;
  width: 50px;
  height: 50px;
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 12px;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.show-layers-btn:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.5);
  transform: translateY(-2px);
}

/* 加载指示器 */
.upload-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 8px;
}

.upload-spinner {
  text-align: center;
  color: #ffffff;
}

.upload-loading-indicator {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid #667eea;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: upload-spin 1s linear infinite;
}

@keyframes upload-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.upload-spinner p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
}

